package cn.dlc.com.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.core.env.Environment;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import cn.dlc.com.property.ZookeeperProperty;
import cn.dlc.com.server.XietiaoServer;

@RestController
@RequestMapping("xietiao")
@EnableConfigurationProperties(ZookeeperProperty.class)
public class TestController {
	
	@Autowired
	private ZookeeperProperty zkProperty;

	@Autowired
	private XietiaoServer xietiaoServer;
	
	@PostMapping("test")
	public String testServerList() {
		// 获取对应的列表
		List<String> serverList = xietiaoServer.getServerList(zkProperty.getNodePath());
		System.out.println("最新的节点：");
		if(serverList != null && serverList.size() > 0) {
			for (String serverUrl : serverList) {
				System.out.println("serverUrl : " + serverUrl);
			}
		}
		return "ok";
	}
}
